#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>

using namespace std;

typedef long long ll;

const int N = 1e7+9;


int n;
bool isPrime[N];
int prime[N];
int k;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	cout<<__gcd(16,24)<<endl;

	cin>>n;
	isPrime[0] = isPrime[1] = false;
	for(int i=2;i<=n;i++){
		isPrime[i] = true;
	}
	for(int i=2;i<=n;i++){
		if(isPrime[i]){
			prime[k++] = i;
		}
		for(int j=0;j<k;j++){
			int x = i*prime[j];
			if(x>n){
				break;
			}
			isPrime[x] = false;
			if(i%prime[j] == 0){
				break;
			}
		}
	}
	for(int i=0;i<k;i++){
		cout<<prime[i]<<" ";
	}cout<<"\n";
	
	
	return 0;
} 
